import {
	GLTFLoader
} from 'three/examples/jsm/loaders/GLTFLoader.js';

let pathArr = ['/moXing/diTu.glb', '/moXing/ren.glb', '/img/danHen.png', '/img/firetorch_1.jpg', '/shengYin/qiangSheng.mp3'];

function zaoPromise(path) {

	const glbLoader = new GLTFLoader();
	const audioLoader = new THREE.AudioLoader();
	const textureLoader = new THREE.TextureLoader();
	
	let p = path.match(/(?<=\.)\w+$/)[0];
	let ming = path.match(/(?<=\/)\w+(?=\.)/)[0];

	switch (p) {

		case 'glb':
			return new Promise((resolve, reject) => {
				glbLoader.load(path, z => resolve(z));
			})

		case 'mp3':
			return new Promise((resolve, reject) => {
				audioLoader.load(path, z => resolve(z));
			})

		case 'png':
		case 'jpg':
			return new Promise((resolve, reject) => {
				textureLoader.load(path, z => resolve(z));
			})
	}

}

function jiaZaiZiYuan() {
	return pathArr.map(path => zaoPromise(path));
}

export default jiaZaiZiYuan;
